import pytest
import requests
class Test_sss():
    token = ""
    addid = ""
    def setup_class(self):
        print("体现类级别,启动函数")
    def teardown_class(self):
        print("体现类级别,钩子函数")
    def setup_function(self):
        print("体现函数级别,启动函数，准备环境")
    def teardown_function(self):
        print("体现函数级别,回收函数，维护环境")
    def setup_mothon(self):
        print("体现方法级别,启动函数")
    def teardown_mothon(self):
        print("体现方法级别,钩子函数")
    def test_login(self):
        url="http://10.59.9.12:7001/api/public/login"
        data={"username":"15821860061","password":"12345678"}
        res = requests.post(url=url,json=data)
        Test_sss.token = res.json()['data']['token']
        Test_sss.token = "Bearer " + Test_sss.token
        print(res.json())
        assert 1 ==res.json()['status']
        assert res.json()['info']=='ok'
        assert 31==res.json()['data']['id']
    def test_list(self):
        url = "http://10.59.9.12:7001/api/point?page=1&type=0&sort=1"
        res = requests.get(url=url)
        print(res.json())
    def test_sp(self):
        url = "http://10.59.9.12:7001/api/point/view?id=5"
        res = requests.get(url=url)
        print(res.json())

    def test_dingdan(self):
        url = "http://10.59.9.12:7001/api/order/confirm?id=4&type=point&sku_id=&num=1&shipping_type=1"
        tou = {"Auth-Token":Test_sss.token}
        res = requests.get(url=url,headers=tou)
        print(res.json())
    def test_chuanghjian(self):
        url = "http://10.59.9.12:7001/api/order/create"
        data={"id":"5","type":"point","address_id":14,"store_id":1,"shipping_type":1,
              "bonus_id":"0","payment":"wechat","remarks":"","source":1,
              "url":"http://10.59.9.12:7001/wap/pages/cart/confirm?id=5&sku_id=&num=1&type=point",
              "sku_id":"","num":"1"}
        tou = {"Auth-Token":Test_sss.token}
        res = requests.post(url=url,json=data,headers=tou)
        print(res.json())
if __name__ == '__main__':
    pytest.main(["-s","A3malljifen"])
